package edu.pku.sei.transformation.tgg.action;

import edu.pku.sei.transformation.codegen.AtomicTransformationCodegenAdapter;
import edu.pku.sei.transformation.editor.model.AtomicTransformation;
import edu.pku.sei.transformation.editor.model.implement.ICodegenElement;
import edu.pku.sei.transformation.tgg.adapter.TGGAdapter;
import edu.pku.sei.transformation.tgg.codegen.TGGGenerator;

public class TGGCodegenAdapter extends AtomicTransformationCodegenAdapter {
	public static final String LANGUAGE = "TGG";
	
	@Override
	public String getLanguage() {
		return LANGUAGE;
	}

	@Override
	public boolean generateCodeToFile(ICodegenElement element, String file) {
		if (!canGenerate(element)) {
			return false;
		} else {
			AtomicTransformation transformation = getAtomicTransformation(element);
			TGGGenerator generator = new TGGGenerator();
			generator.generate(new TGGAdapter(transformation), file);
			return true;
		}
	}

	@Override
	public String getFileName(ICodegenElement element) {
		if (canGenerate(element)) {
			return getAtomicTransformation(element).getName()+".tgg";
		} else {
			return "null";
		}
	}


}
